package vn.edu.vttu.changebackground;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class ChooseColor extends Activity {
	RadioGroup radioGroup;
	private RadioButton radioButton;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_choose_color);
		radioGroup = (RadioGroup)findViewById(R.id.radioGroup);
	}
	public void choose(View view) {
		// TODO Auto-generated method stub
		int selectedId = radioGroup.getCheckedRadioButtonId();
    	radioButton = (RadioButton) findViewById(selectedId);
    	String colorChoice = radioButton.getText().toString();
			//dong goi du lieu tra ve
    	Intent intent = new Intent();
    	if(colorChoice.trim().equals("RED")){
    		intent.putExtra("colored", Color.RED);
    	}
    	else if(colorChoice.trim().equals("YELLOW")){
    		intent.putExtra("colored", Color.YELLOW);
    	}
    	else if(colorChoice.trim().equals("BLUE")){
    		intent.putExtra("colored", Color.BLUE);
    	}
    	else if(colorChoice.trim().equals("GREEN")){
    		intent.putExtra("colored", Color.GREEN);
    	}
    	else if(colorChoice.trim().equals("CYAN")){
    		intent.putExtra("colored", Color.CYAN);
    	}
    	else if(colorChoice.trim().equals("GRAY")){
        	intent.putExtra("colored", Color.GRAY);
        }
        else if(colorChoice.trim().equals("WHITE")){
        intent.putExtra("colored", Color.WHITE);
        }
        else if(colorChoice.trim().equals("MAGENTA")){
    		intent.putExtra("colored", Color.MAGENTA);
    	}
    	else if(colorChoice.trim().equals("GRAY")){
        	intent.putExtra("colored", Color.GRAY);
        }
        else if(colorChoice.trim().equals("WHITE")){
        intent.putExtra("colored", Color.WHITE);
        }
    	setResult(RESULT_OK,intent);
    	Toast.makeText(getApplicationContext(), "Ban vua chon mau: "+ radioButton.getText(), 1000).show();
    	finish();
	}
	}
